package com.lexed.jdbc.config;

import org.dom4j.Document;
import org.dom4j.io.SAXReader;

public class Config {

	public static final String DRIVER;
	public static final String URL;
	public static final String USERNAME;
	public static final String PASSWORD;
	
	private static Document document = null;
	
	static{ // 静态代码块  类被加载时执行
		
		try {
			
			SAXReader reader = new SAXReader();
			document = reader.read("config.xml");
		} catch (Exception e) {
			
		}
		DRIVER =document!=null ? document.selectSingleNode("//jdbc/driver").getText().trim():"";
		URL =document!=null ?document.selectSingleNode("//jdbc/url").getText().trim():"";
		USERNAME =document!=null ?document.selectSingleNode("//jdbc/username").getText().trim():"";
		PASSWORD =document!=null ?document.selectSingleNode("//jdbc/password").getText().trim():"";
	}
	
	
}
